package mx.com.initzero.ecommerce.utils.mail;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.*;

public class Mail {


private JavaMailSenderImpl mailSender;
public Mail(){

}

public void setMailSender(JavaMailSenderImpl mailSender) {
this.mailSender = mailSender;
}

public JavaMailSenderImpl getMailSender() {
return mailSender;
}

public void sendMail(String to, String subject, String msg) {
try {
	MimeMessage message = mailSender.createMimeMessage();
	MimeMessageHelper helper = new MimeMessageHelper(message, true);
	helper.setFrom("ritmostony@gmail.com");
	helper.setTo(to);
	helper.setSubject(subject);
	helper.setText(msg);
	
	mailSender.send(message);

// MimeMessageHelper helper = new MimeMessageHelper(message, true);

// SimpleMailMessage message = new SimpleMailMessage();

// message.setFrom("japs8704@gmail.com");
// message.setTo(to);
// message.setSubject(subject);
// message.setText(msg);
// 
// mailSender.send(message);
// message = getMailSender().createMimeMessage();
} catch (MessagingException ex) {
Logger.getLogger(Mail.class.getName()).log(Level.SEVERE, null, ex);
}
}
}